<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="zh-tw">

  <head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	</head>
	<body>
	<form method="post">
<?php
//echo '$app_list_strings = array (';
$bk = chr(10);
$qo = '  ';
//echo $string = chr(60).'?php'.$bk.'$';
$string = '';
$lang = "zh_cn";
@unlink('include/language/'.$lang.'.lang.php_old');
@copy('include/language/'.$lang.'.lang.php', 'include/language/'.$lang.'.lang.php_old');
if(isset($_POST['go']) && $_POST['go']){
  $fd = fopen('include/language/'.$lang.'.lang.php', 'w');
  fwrite($fd, '<?php'.$bk.'$app_strings = array ('.$bk);
  //fwrite($fd, $bk.');'.$bk.'$app_strings = array ('.$bk);
  $string = '';
  foreach($_POST['app_strings'] as $key1 => $arr){
    if(is_array($arr)){
      $string .= $qo.'\''.$key1.'\' =>'.$bk.$qo.'array ('.$bk;
      foreach($arr as $key2 => $string1){
        $string .= $qo.$qo.'\''.$key2.'\' => \''.$string1.'\','.$bk;
      }
      $string .= $qo.'),'.$bk;
    } else {
	  //echo $key1.'<p>';
      $string .= $qo.'\''.$key1.'\' => \''.$arr.'\','.$bk;
    }
  }
  fwrite($fd, $string);
  $string = '';
  //fwrite($fd, '<?php'.$bk.'$app_list_strings = array ('.$bk);
  fwrite($fd, $bk.');'.$bk.'$app_list_strings = array ('.$bk);
  //$string .= 'app_list_strings = array ('.$bk;
  foreach($_POST['app_list_strings'] as $key1 => $arr){
    if(is_array($arr)){
      $string .= $qo.'\''.$key1.'\' =>'.$bk.$qo.'array ('.$bk;
      foreach($arr as $key2 => $string1){
        $string .= $qo.$qo.'\''.$key2.'\' => \''.$string1.'\','.$bk;
      }
      $string .= $qo.'),'.$bk;
    } else {
      $string .= $qo.'\''.$key1.'\' => \''.$arr.'\','.$bk;
    }
  }
  fwrite($fd, $string);
  
  fwrite($fd, $bk.');'.$bk.'?>');
}
?> </pre><?php
include 'include/language/en_us.lang.php';
$en_app_list_strings = $app_list_strings;
$en_app_strings = $app_strings;
include 'include/language/'.$lang.'.lang.php_old';

$tmpArray = array();
foreach ($app_list_strings as $key => $value) {
	if(array_key_exists($key,$en_app_list_strings)) {
		$valueArray = array();
		if(is_array($value)) {
			foreach($value as $key1 => $value1) {
				if(array_key_exists($key1,$en_app_list_strings[$key])) {
					$valueArray[$key1] = $value1;
				}
			}
			$tmpArray[$key] = $valueArray;
		} else {
			$tmpArray[$key] = $value;
		}
	}
}
$app_list_strings = $tmpArray;



$result1 = array_merge($en_app_list_strings, $app_list_strings);

$tmpArray2 = array();
foreach($app_strings as $key2 => $value2) {
	if(array_key_exists($key2,$en_app_strings)) {
		$tmpArray2[$key2] = $value2;
	}
}
$app_strings = $tmpArray2;
$result2 = array_merge($en_app_strings, $app_strings);

foreach($result1 as $key => $arr){
  if(is_array($arr)){
    //echo $key.'<p>';
	if(is_array($app_list_strings[$key])) {
	    $result3 = array_merge($en_app_list_strings[$key],$app_list_strings[$key]);
	} else {
		$result3= $en_app_list_strings[$key];
	}
    foreach($result3 as $key2 => $string){
      echo '<input type="text" name="app_list_strings['.$key.']['.$key2.']" value="'.$string.'"><br>';
    }
  } else {
    echo '<input type="text" name="app_list_strings['.$key.']" value="'.$arr.'"><br>';
  }
}

foreach($result2 as $key => $arr){
  if(is_array($arr)){
    //echo $key.'<p>';
    foreach($arr as $key2 => $string){
      echo '<input type="text" name="app_strings['.$key.']['.$key2.']" value="'.$string.'"><br>';
    }
  } else {
	//echo $key.'<p>';
    echo '<input type="text" name="app_strings['.$key.']" value="'.$arr.'"><br>';
  }
}
?>
<input type="submit" name="go" value="go">
</form>
</body>
</html>